package com.czy.utils;

import java.util.Random;

/**
 * 随机数工具类
 * @author czy
 * @date 2021-5-20 11:09
 */
public class RandomUtil {
    /**
     * 随机数生成无边界的Int
     */
    public static int getRandomForIntegerUnbounded() {
        int intUnbounded = new Random().nextInt();
        System.out.println(intUnbounded);
        return intUnbounded;
    }

    /**
     * 生成有边界的Int
     * @param min   最小值
     * @param max   最大值
     * @return
     */
    public static int getRandomForIntegerBounded(int min, int max) {
        int intBounded = min + ((int) (new Random().nextFloat() * (max - min)));
        System.out.println(intBounded);
        return intBounded;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10000; i++) {
            System.out.println((int)(Math.random()*3));
        }
    }
}
